/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package sv.com.bolsaTrabajo.model.entities;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author sysmanager
 */
@Entity
@Table(catalog = "bolsadetrabajo", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Persona.findAll", query = "SELECT p FROM Persona p"),
    @NamedQuery(name = "Persona.findByIdPersona", query = "SELECT p FROM Persona p WHERE p.idPersona = :idPersona"),
    @NamedQuery(name = "Persona.findByNombres", query = "SELECT p FROM Persona p WHERE p.nombres = :nombres"),
    @NamedQuery(name = "Persona.findByApellidos", query = "SELECT p FROM Persona p WHERE p.apellidos = :apellidos"),
    @NamedQuery(name = "Persona.findByNatalicio", query = "SELECT p FROM Persona p WHERE p.natalicio = :natalicio"),
    @NamedQuery(name = "Persona.findByPrivacidad", query = "SELECT p FROM Persona p WHERE p.privacidad = :privacidad"),
    @NamedQuery(name = "Persona.findByEsExtranjero", query = "SELECT p FROM Persona p WHERE p.esExtranjero = :esExtranjero"),
    @NamedQuery(name = "Persona.findByGenero", query = "SELECT p FROM Persona p WHERE p.genero = :genero")})
public class Persona implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id_persona", nullable = false)
    private Integer idPersona;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 255)
    @Column(nullable = false, length = 255)
    private String nombres;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 255)
    @Column(nullable = false, length = 255)
    private String apellidos;
    @Basic(optional = false)
    @NotNull
    @Column(nullable = false)
    @Temporal(TemporalType.DATE)
    private Date natalicio;
    @Basic(optional = false)
    @NotNull
    @Column(nullable = false)
    private char privacidad;
    @Size(max = 5)
    @Column(name = "es_extranjero", length = 5)
    private String esExtranjero;
    private Character genero;
    @JoinTable(name = "persona_tipo_jornada", joinColumns = {
        @JoinColumn(name = "id_persona", referencedColumnName = "id_persona", nullable = false)}, inverseJoinColumns = {
        @JoinColumn(name = "id_tipo_jornada", referencedColumnName = "id_tipo_jornada", nullable = false)})
    @ManyToMany(fetch = FetchType.LAZY)
    private Collection<TipoJornada> tipoJornadaCollection;
    @OneToMany(mappedBy = "idPersona", fetch = FetchType.LAZY)
    private Collection<Direccion> direccionCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idPersona", fetch = FetchType.LAZY)
    private Collection<Postulacion> postulacionCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "persona", fetch = FetchType.LAZY)
    private Collection<IdiomaPersona> idiomaPersonaCollection;
    @OneToMany(mappedBy = "idPersona", fetch = FetchType.LAZY)
    private Collection<ContactoEntidad> contactoEntidadCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idPersona", fetch = FetchType.LAZY)
    private Collection<DetalleEstudio> detalleEstudioCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idPersona", fetch = FetchType.LAZY)
    private Collection<HabilidadesExtras> habilidadesExtrasCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idPersona", fetch = FetchType.LAZY)
    private Collection<Curriculum> curriculumCollection;
    @JoinColumn(name = "id_rubro", referencedColumnName = "id_rubro", nullable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Rubro idRubro;
    @JoinColumn(name = "id_estado_civ", referencedColumnName = "id_estado_civ", nullable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private EstadoCivil idEstadoCiv;
    @JoinColumn(name = "id_usuario", referencedColumnName = "id_usuario", nullable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Usuario idUsuario;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idPersona", fetch = FetchType.LAZY)
    private Collection<DetalleHabilidades> detalleHabilidadesCollection;

    public Persona() {
    }

    public Persona(Integer idPersona) {
        this.idPersona = idPersona;
    }

    public Persona(Integer idPersona, String nombres, String apellidos, Date natalicio, char privacidad) {
        this.idPersona = idPersona;
        this.nombres = nombres;
        this.apellidos = apellidos;
        this.natalicio = natalicio;
        this.privacidad = privacidad;
    }

    public Integer getIdPersona() {
        return idPersona;
    }

    public void setIdPersona(Integer idPersona) {
        this.idPersona = idPersona;
    }

    public String getNombres() {
        return nombres;
    }

    public void setNombres(String nombres) {
        this.nombres = nombres;
    }

    public String getApellidos() {
        return apellidos;
    }

    public void setApellidos(String apellidos) {
        this.apellidos = apellidos;
    }

    public Date getNatalicio() {
        return natalicio;
    }

    public void setNatalicio(Date natalicio) {
        this.natalicio = natalicio;
    }

    public char getPrivacidad() {
        return privacidad;
    }

    public void setPrivacidad(char privacidad) {
        this.privacidad = privacidad;
    }

    public String getEsExtranjero() {
        return esExtranjero;
    }

    public void setEsExtranjero(String esExtranjero) {
        this.esExtranjero = esExtranjero;
    }

    public Character getGenero() {
        return genero;
    }

    public void setGenero(Character genero) {
        this.genero = genero;
    }

    @XmlTransient
    public Collection<TipoJornada> getTipoJornadaCollection() {
        return tipoJornadaCollection;
    }

    public void setTipoJornadaCollection(Collection<TipoJornada> tipoJornadaCollection) {
        this.tipoJornadaCollection = tipoJornadaCollection;
    }

    @XmlTransient
    public Collection<Direccion> getDireccionCollection() {
        return direccionCollection;
    }

    public void setDireccionCollection(Collection<Direccion> direccionCollection) {
        this.direccionCollection = direccionCollection;
    }

    @XmlTransient
    public Collection<Postulacion> getPostulacionCollection() {
        return postulacionCollection;
    }

    public void setPostulacionCollection(Collection<Postulacion> postulacionCollection) {
        this.postulacionCollection = postulacionCollection;
    }

    @XmlTransient
    public Collection<IdiomaPersona> getIdiomaPersonaCollection() {
        return idiomaPersonaCollection;
    }

    public void setIdiomaPersonaCollection(Collection<IdiomaPersona> idiomaPersonaCollection) {
        this.idiomaPersonaCollection = idiomaPersonaCollection;
    }

    @XmlTransient
    public Collection<ContactoEntidad> getContactoEntidadCollection() {
        return contactoEntidadCollection;
    }

    public void setContactoEntidadCollection(Collection<ContactoEntidad> contactoEntidadCollection) {
        this.contactoEntidadCollection = contactoEntidadCollection;
    }

    @XmlTransient
    public Collection<DetalleEstudio> getDetalleEstudioCollection() {
        return detalleEstudioCollection;
    }

    public void setDetalleEstudioCollection(Collection<DetalleEstudio> detalleEstudioCollection) {
        this.detalleEstudioCollection = detalleEstudioCollection;
    }

    @XmlTransient
    public Collection<HabilidadesExtras> getHabilidadesExtrasCollection() {
        return habilidadesExtrasCollection;
    }

    public void setHabilidadesExtrasCollection(Collection<HabilidadesExtras> habilidadesExtrasCollection) {
        this.habilidadesExtrasCollection = habilidadesExtrasCollection;
    }

    @XmlTransient
    public Collection<Curriculum> getCurriculumCollection() {
        return curriculumCollection;
    }

    public void setCurriculumCollection(Collection<Curriculum> curriculumCollection) {
        this.curriculumCollection = curriculumCollection;
    }

    public Rubro getIdRubro() {
        return idRubro;
    }

    public void setIdRubro(Rubro idRubro) {
        this.idRubro = idRubro;
    }

    public EstadoCivil getIdEstadoCiv() {
        return idEstadoCiv;
    }

    public void setIdEstadoCiv(EstadoCivil idEstadoCiv) {
        this.idEstadoCiv = idEstadoCiv;
    }

    public Usuario getIdUsuario() {
        return idUsuario;
    }

    public void setIdUsuario(Usuario idUsuario) {
        this.idUsuario = idUsuario;
    }

    @XmlTransient
    public Collection<DetalleHabilidades> getDetalleHabilidadesCollection() {
        return detalleHabilidadesCollection;
    }

    public void setDetalleHabilidadesCollection(Collection<DetalleHabilidades> detalleHabilidadesCollection) {
        this.detalleHabilidadesCollection = detalleHabilidadesCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idPersona != null ? idPersona.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Persona)) {
            return false;
        }
        Persona other = (Persona) object;
        if ((this.idPersona == null && other.idPersona != null) || (this.idPersona != null && !this.idPersona.equals(other.idPersona))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "sv.com.bolsaTrabajo.controller.Persona[ idPersona=" + idPersona + " ]";
    }
    
}
